package com.scpcfe.www.service;


import com.scpcfe.www.dao.StudentInfoDao;
import com.scpcfe.www.entity.StudentInfoEntity;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class StudentInfoService {
    @Autowired//自动装配，自动给他创建一个对象并实列化
    StudentInfoDao studentInfoDao;
    public static StudentInfoService studentInfoService;//单列模式（内存中保留一份对象)

    @PostConstruct
    public void init() {
        studentInfoService = this;
        studentInfoService.studentInfoDao = this.studentInfoDao;
    }

    public List<StudentInfoEntity> getStudentInfo(String stuId) {

        return studentInfoDao.getStudentInfo(stuId);
    }

    public List<StudentInfoEntity> getAge(String stuId) {
        return studentInfoDao.getStudentInfo(stuId);
    }

    public int insertStudentInfo(String stuId, String stuName, String className) {
        return studentInfoDao.insertStudentInfo(stuId, stuName, className);
    }

    public int updataStudentAge(String stuId) {
        return studentInfoDao.updateStudentAge(stuId);
    }

    public int deletStudentInfo(String stuId) {
        return studentInfoDao.deletStudentInfo(stuId);
    }
}



